<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/main.css" />
	</head>

	<body class="talentpage">
		<header class="mui-bar mui-bar-nav">
			<h1 class="mui-title">达人说</h1>
		</header>

		<div class="mui-content">

		</div>

		<script type="text/template" id="talentTpl">
			{{each talent item idx}}
			<div class="card-wrap" onclick="toarticle('{{item.id}}')">
				<img class="lazy pic" data-src="{{item.article_banner}}" />
				<div class="title">{{item.name}}</div>
				<div class="info-wrap">
					<img class="avatar" src="{{item.head_img}}" />
					<span class="nickname">{{item.talent_name}}</span>
					<img class="eye" src="../imgs/eye.png" />
					<span>{{item.readtimes}}</span>
				</div>
			</div>
			{{/each}}

		</script>
		<script src="../js/mui.min.js"></script>
		<script type="text/javascript" src="../js/template-web.js"></script>
		<script type="text/javascript" src="../js/zepto113.js"></script>
		<script type="text/javascript" src="../js/lazyload.js"></script>
		<script type="text/javascript" src="../js/api.js"></script>
		<script type="text/javascript">
			mui.init({
				pullRefresh: {
					container: "body", //下拉刷新容器标识，querySelector能定位的css选择器均可，比如：id、.class等
					down: {
						style: 'circle', //必选，下拉刷新样式，目前支持原生5+ ‘circle’ 样式
						color: '#FE413F', //可选，默认“#2BD009” 下拉刷新控件颜色
						height: '50px', //可选,默认50px.下拉刷新控件的高度,
						range: '100px', //可选 默认100px,控件可下拉拖拽的范围
						offset: '50px', //可选 默认0px,下拉刷新控件的起始位置
						auto: false, //可选,默认false.首次加载自动上拉刷新一次
						callback: function() { //必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据；
							mui('body').pullRefresh().endPulldown();
						}
					}
				},
			})

			mui.plusReady(function() {

				api.getTalent(function(res) {
					if (res.code == 1) {

						var html = template('talentTpl', {
							talent: res.data.newdata,
						})

						$(".mui-content").html(html)

						myLazyLoad.update()
					}

				})
			})

			function toarticle(id) {
				mui.openWindow({
					url: "talent-art.html",
					id: "talent-art",
					extras: {
						aid: id
					}
				})
			}

			//图片懒加载器
			var myLazyLoad = new LazyLoad({
				elements_selector: ".lazy"
			});
		</script>
	</body>

</html>
